package Week5.J0515;

import java.util.Scanner;

public class kotori和气球_xv {
    static int MOD = 109;
    
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int ret = n;
        for (int i = 0; i < m-1; i++) {
            ret = ret * (n - 1) % MOD;
        }

        System.out.println(ret);
    }
}
